<?php
//控制器基类
class Controller {
    protected $tpl = null;
    protected $model = null;
    protected $redirect = null;
    protected function __construct() {
        $this->tpl = TPL::getInstance();
        $this->model = Factory::setModel();
        $this->redirect = Redirect::getInstance($this->tpl);
    }
    protected function page($pageSize = PAGE_SIZE) {
            $page = new Page($this->model->total(),$pageSize);
            //var_dump($this->model->total());
            $this->model->setLimit($page->getLimit());
            if($this->model->total() > $pageSize)
            $this->tpl->assign('pagination',$page->showPagination());
            //$this->tpl->assign('num',($page->getCurrentPage()-1)*$pageSize);
    }
    /**
     * 执行控制器里的相应方法
     */
    public function run() {
        $m = isset($_GET['m']) ? $_GET['m'] : 'index';
        method_exists($this,$m) ? eval('$this->'.$m.'();') : $this->index();
    }
}